# frozen_string_literal: true

require "openssl"

module Clec::Cert
  EC_KEY_PEM = <<PEM
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIDDAkD1XI3IF872unw/StNAphPL9NEXTQzacy4z0rLzOoAoGCCqGSM49
AwEHoUQDQgAEDnrLgCSo59ByurSxcCc358X1bOuA7SJnMUz6NtLN/v+iRtnPoFJe
WmkoGe6l47UAqarOGVVt5S6VAMdjNX5JLQ==
-----END EC PRIVATE KEY-----
PEM

  EC_CERTIFICATE_PEM = <<PEM
-----BEGIN CERTIFICATE-----
MIIBQzCB6aADAgECAhEA/YYxV9yVitX9poeY4QJPBjAKBggqhkjOPQQDAjAiMSAw
HgYDVQQDDBdjbG92ZXItdGVzdC1jZXJ0aWZpY2F0ZTAgFw0yNDEwMjYwNzE1NTla
GA8zMDI0MDIyNzA3MTU1OVowIjEgMB4GA1UEAwwXY2xvdmVyLXRlc3QtY2VydGlm
aWNhdGUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQOesuAJKjn0HK6tLFwJzfn
xfVs64DtImcxTPo20s3+/6JG2c+gUl5aaSgZ7qXjtQCpqs4ZVW3lLpUAx2M1fkkt
MAoGCCqGSM49BAMCA0kAMEYCIQClTTTc+pAH5u74NHl3rPpNTd0M4lDblCiFdxr+
U1tSngIhAL2CqlBJbCuTQTH0QKs0WPKGb1ao4KzMfRJz2SFv7iMS
-----END CERTIFICATE-----
PEM

  RSA_CERTIFICATE_PEM = <<PEM
-----BEGIN CERTIFICATE-----
MIIBTDCB96ADAgECAhEAr1KXe6x8o37Nqcge9yfi1zANBgkqhkiG9w0BAQsFADAm
MSQwIgYDVQQDDBtjbG92ZXItdGVzdC1yc2EtY2VydGlmaWNhdGUwIBcNMjQxMDI2
MTYyNjA3WhgPMzAyNDAyMjcxNjI2MDdaMCYxJDAiBgNVBAMMG2Nsb3Zlci10ZXN0
LXJzYS1jZXJ0aWZpY2F0ZTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDgKL3mYnL1
JUuErKZMYbwdqtXNwoJInqCeGG2MrCOUjjP33IUW5Zxg0XOE0dsktvo70uBVLn1D
5MBunbkSSSbbAgMBAAEwDQYJKoZIhvcNAQELBQADQQDI3w6lLWxWVNt1U/lb6D8l
IboYe/jgIEvo+cXQ94SXMc8yktnsiUGK59vgrY5OQg9icMc2u8KzXZIl7rz05tV3
-----END CERTIFICATE-----
PEM

  RSA_KEY_PEM = <<PEM
-----BEGIN RSA PRIVATE KEY-----
MIIBOgIBAAJBAOAoveZicvUlS4SspkxhvB2q1c3CgkieoJ4YbYysI5SOM/fchRbl
nGDRc4TR2yS2+jvS4FUufUPkwG6duRJJJtsCAwEAAQJAZPVUmkfq+MiEW8wa1joK
rN39j7+0SBrRwoLEDGCXYddWEdd3evVqkACw5ltrfF6ZX3R5sbbt/TVD7UqjVjxd
UQIhAP8AU9DZOHWBLAiI/T3FNm+kBQAMRP4gNBtShytmv9lJAiEA4Ql9tm52dKG+
t8GkDCeapjUOG1iYmQbraW0bJz5PwwMCID4OiVdBFcFa3ylwlRiMPvQqWWEqmzux
AJ1Jl0WTqsqpAiAgav6aJkWYPai8zf905Mupf+EdXWD2QoHtORN9TsOswwIhAKZt
LEEA3aGa0Mos4PapmD6O39jaJLrAl91UprvouUjv
-----END RSA PRIVATE KEY-----
PEM

  class << self
    def ec_key
      @ec_key ||= OpenSSL::PKey::EC.new(EC_KEY_PEM).freeze
    end

    def ec_certificate
      @ec_public_key ||= OpenSSL::PKey::EC.new(EC_CERTIFICATE_PEM).freeze
    end

    def rsa_key
      @rsa_key ||= OpenSSL::PKey::RSA.new(RSA_KEY_PEM).freeze
    end

    def rsa_certificate
      @rsa_public_key ||= OpenSSL::PKey::RSA.new(RSA_CERTIFICATE_PEM).freeze
    end
  end
end
